package com.liucxu.qiushimeinv.View.Activity;

import android.support.design.widget.Snackbar;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.liucxu.qiushimeinv.App.App;
import com.liucxu.qiushimeinv.Base.BaseActivity;
import com.liucxu.qiushimeinv.Model.Bean.BaseBean;
import com.liucxu.qiushimeinv.Presenter.IPayFeedbackPresenter;
import com.liucxu.qiushimeinv.Presenter.Impl.PayFeedbackPresenterImpl;
import com.liucxu.qiushimeinv.R;
import com.liucxu.qiushimeinv.View.IView.IPayFeedbackView;

/**
 * 注册画面实现Activity
 * Created by liukanshan on 2017/1/5.
 */

public class PayFeedbackActivity extends BaseActivity implements IPayFeedbackView {

    private Toolbar toolbar;
    private EditText pay_count;
    private Button submit_count_info;
    private IPayFeedbackPresenter presenter;

    @Override
    public void initBeforeView() {

    }

    @Override
    public int getInflateLayout() {
        return R.layout.activity_submit_count_info;
    }

    @Override
    public void setupView() {
        toolbar = $(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        pay_count = (EditText) findViewById(R.id.pay_count);
        submit_count_info = (Button) findViewById(R.id.submit_count_info);
        submit_count_info.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.isEmpty(pay_count.getText())) {
                    Snackbar.make(pay_count, "请输入转账账号", Snackbar.LENGTH_SHORT).show();
                } else {
                    submitAliInfo(pay_count.getText().toString());
                }
            }
        });
        presenter=new PayFeedbackPresenterImpl(this);
    }

    @Override
    public void setupData() {

    }

    @Override
    public void submitAliInfo(String aliCount) {
        presenter.submitUserCountInfo(aliCount);
    }

    @Override
    public void feedbackSuccess() {
        Toast.makeText(App.GetInstance(),"反馈成功，等待客服开启",Toast.LENGTH_SHORT).show();
        this.finish();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void showLoading() {
        dialog.show();
    }

    @Override
    public void hideLoading() {
        dialog.hide();
    }

    @Override
    public void showError(BaseBean bean) {
        Snackbar.make(submit_count_info, bean.getDesc(), Snackbar.LENGTH_SHORT);
    }
}
